<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

require '../lib/util.php';
$userName = $_REQUEST['txtUserName'];
$password = $_REQUEST['txtEncPassword'];
session_start();

$sql = "SELECT * FROM SYSTEM_USER_INFO WHERE UserName = '$userName'";
$rs = executeSqlQuery($sql);
$rowCount = mysql_num_rows($rs);

if ($rowCount == 1)
{
    $dataTuple = mysql_fetch_array($rs);
    if ($password == $dataTuple['Password'])
    {
        //echo "hi";
        
        //session_start();
        $_SESSION['UserID'] = $dataTuple['ID'];
        $_SESSION['UserFirstName'] = $dataTuple['StaffFirstName'];
        $_SESSION['UserLastName'] = $dataTuple['StaffLastName'];
        $_SESSION['UserRole'] = $dataTuple['UserRole'];
        header("Location:../index.php");
    }
    else
    {
        $_SESSION['ErrorMsg'] = "Invalid Password. Please use correct password to login to LIMS.";
        header("Location:../index.php");
    }
}
 else
{
    $_SESSION['ErrorMsg'] = "Username is not exist.";
    header("Location:../index.php");
}
?>
